package com.gitee.jjnnzb.designpatterndemo.controller;

import com.gitee.jjnnzb.designpatterndemo.entity.bo.UrlInput;
import com.gitee.jjnnzb.designpatterndemo.entity.vo.ResponseRt;
import com.gitee.jjnnzb.designpatterndemo.service.UrlService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Jjn
 * @since 2023/3/6 18:37
 */
@RestController
@RequiredArgsConstructor
public class UrlController {
    
    private final UrlService urlService;
    
    @PostMapping(value = "/api/v1/urls")
    public ResponseRt getUrls(@RequestBody UrlInput urlInput) {
        return new ResponseRt().setCode(HttpStatus.OK.value())
                .setMessage(HttpStatus.OK.name())
                .setData(urlService.handleInputUrls(urlInput));
    }
}
